/**
 * This script contains tests for the FlyTED Sparql Endpoint.
 * @author Alistair Miles
 * @author Jun Zhao
 */
// convenience variables
var Assert = YAHOO.util.Assert;
var log = YAHOO.log;
var JSON = YAHOO.lang.JSON;
var sparqlns = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ";
sparqlns += "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ";
sparqlns += "PREFIX flyted: <http://purl.org/net/flyted/schema/> ";
sparqlns += "PREFIX so: <http://purl.org/obo/owl/SO#>";


function testEndpointExists(testcase) {

	// define the callback object
	var callback = {
		success: testEndpointExistsResponseSuccess(testcase),
		failure: testEndpointExistsResponseFailure(testcase)
	};
	
	log("Make the request");
	var request = YAHOO.util.Connect.asyncRequest("GET", "flyted", callback, null);
	
	log("Suspend the test runner");
	testcase.wait();
	
	log("N.B. this code should never be reached.");
}

function testEndpointHasData(testcase) {
	var query = "ASK { ?subject ?predicate ?object }";
	testAskQuery("flyted", testcase, query, true, "Endpoint has no data.");
}

function testEndpointHasImages(testcase) {
	var query = "ASK { ?image rdf:type flyted:Image }";
	testAskQuery("flyted", testcase, query, true, "Endpoint has no images.");
}

function testEndpointImageURIsAreValid(testcase) {
	var query = "ASK { ?image rdf:type flyted:Image FILTER ( isIRI(?image) && regex(str(?image), '^http://') ) }";
	testAskQuery("flyted", testcase, query, true, "Expected image URIs to start with 'http://'.");
}

function testEndpointHasImagesWithProbes(testcase) {
    YAHOO.log("testEndpointHasImagesWithProbes");
	var query = "ASK { ?image rdf:type flyted:Image ; flyted:probe ?probe . }";
	testAskQuery("flyted", testcase, query, true, "Endpoint has no images with probes.");
}

function testEndpointHasNoImagesWithoutProbes(testcase) {
    YAHOO.log("testEndpointHasNoImagesWithoutProbes");
	var query = "ASK { ?image rdf:type flyted:Image . OPTIONAL {?image flyted:probe ?probe }. FILTER ( !bound(?probe)) }";
	testAskQuery("flyted", testcase, query, false, "Expected no images without probes.");	
}

function testEndpointHasImagesWithSpecificProbe(testcase, probe, expected) {
    YAHOO.log("testEndpointHasImagesWithSpecificProbe: "+probe);
	var query = "ASK {?image flyted:probe ?probe ." +
			"?probe rdfs:label '" + probe + "'}";
	var message = "There should be at least one image for probe '"+probe+"'.";
	testAskQuery("flyted", testcase, query, expected, message);	
}

function testEndpointHasImageWithThumbnails (testcase) {
    YAHOO.log("testEndpointHasImageWithThumbnails");
	var query = "ASK { ?image rdf:type flyted:Image ; flyted:thumbnail ?thumbnail . }";
	testAskQuery("flyted", testcase, query, true, "Endpoint has no images with thumbnails.");
}

function testEndpointHasNoImagesWithoutThumbnails (testcase) {
    YAHOO.log("testEndpointHasNoImagesWithoutThumbnails");
	var query = "ASK { ?image rdf:type flyted:Image . OPTIONAL {?image flyted:thumbnail ?thumbnail }. FILTER ( !bound(?thumbnail)) }";
	testAskQuery("flyted", testcase, query, false, "Endpoint has images without thumbnails.");
}

function testEndpointHasImageWithSeeAlso (testcase) {
    YAHOO.log("testEndpointHasImageWithSeeAlso");
	var query = "ASK { ?image rdf:type flyted:Image ; rdfs:seeAlso ?seeAlso . }";
	testAskQuery("flyted", testcase, query, true, "Expected images are linked with a see also.");
}

function testEndpointHasNoImagesWithoutSeeAlso (testcase) {
    YAHOO.log("testEndpointHasNoImagesWithoutSeeAlso");
	var query = "ASK { ?image rdf:type flyted:Image . OPTIONAL {?image rdfs:seeAlso ?seeAlso }. FILTER ( !bound(?seeAlso)) }";
	testAskQuery("flyted", testcase, query, false, "Expected no images without linked with a see also.");
}

function testEndpointHasImageWithGenotype(testcase) {
    YAHOO.log("testEndpointHasImageWithGenotype");
	var query = "ASK { ?image rdf:type flyted:Image ; flyted:genotype ?genotype . }";
	testAskQuery("flyted", testcase, query, true, "Expected images with a genotype.");
}

function testEndpointHasNoImagesWithoutGenotype (testcase) {
	YAHOO.log("testEndpointHasNoImagesWithoutGenotype");
	var query = "ASK { ?image rdf:type flyted:Image . OPTIONAL {?image flyted:genotype ?genotype }. FILTER ( !bound(?genotype)) }";
	testAskQuery("flyted", testcase, query, true, "Expected no images without a genotype.");
}

function testEndpointHasImagesWithSpecificGenotype(testcase, genotype) {
    YAHOO.log("testEndpointHasImagesWithSpecificGenotype: "+genotype);
	var query = "ASK {?image flyted:genotype <http://openflydata.org/id/flyted/strain/"+genotype+">}";
	var message = "There should be at least one image for genotype '"+genotype+"'.";
	testAskQuery("flyted", testcase, query, true, message);
}

function testEndpointHasImageWithExpressions(testcase) {
    YAHOO.log("testEndpointHasImageWithExpressions");
	var query = "ASK { ?image rdf:type flyted:Image ; flyted:expression ?expression . }";
	testAskQuery("flyted", testcase, query, true, "Expected images with an expression location.");
}

function testEndpointHasNoImagesWithoutExpressions (testcase) {
	var query = "ASK { ?image rdf:type flyted:Image . OPTIONAL {?image flyted:expression ?expression }. FILTER ( !bound(?expression)) }";
	testAskQuery("flyted", testcase, query, true, "Expected no images without a expression.");
}

function testEndpointHasImagesWithSpecificExpression(testcase, expression) {
    YAHOO.log("testEndpointHasImagesWithSpecificExpression: "+expression);
	var query = "ASK {?image flyted:expression <http://openflydata.org/id/flyted/expression/"+expression+">}";
	var message = "There should be at least one image for expression '"+expression+"'.";
	testAskQuery("flyted", testcase, query, true, message);
}

function testEndpointHasFlyBaseGeneFeature (testcase){
	YAHOO.log("testEndpointHasFlyBaseGeneFeature");
	var query = "ASK {?feature rdf:type so:SO_0000704}";
	var message = "There should be at least one flybase gene feature";
	testAskQuery("flyted", testcase, query, true, message);
}


function testEndpointHasProbesWithGeneMappings (testcase) {
	YAHOO.log("testEndpointHasProbesWithGeneMappings");
	var query = "ASK {?probe flyted:hybridisesTranscriptOf ?feature. ?feature rdf:type so:SO_0000704}";
	var message = "There should be at least one probe with gene mappings";
	testAskQuery("flyted", testcase, query, true, message);	
}

function testEndpointNotHasSpecificProbes (testcase, probe){
	YAHOO.log("testEndpointNotHasSpecificProbes: " + probe);
	var query = "ASK {<http://openflydata.org/id/flyted/probe/" + probe + "> flyted:hybridisesTranscriptOf ?feature .}";
	var message = "There should be no flybase genes mapped to the probe; " + probe;
	testAskQuery("flyted", testcase, query, false, message);
} 

function testEndpointHasGeneMappingForSpecificProbes (testcase, probe){
	YAHOO.log("testEndpointNotHasSpecificProbes: " + probe);
	var query = "ASK {?probe flyted:hybridisesTranscriptOf ?feature; rdfs:label '" + probe + "'}";
	var message = "There should be no flybase genes mapped to the probe; " + probe;
	testAskQuery("flyted", testcase, query, true, message);
} 

function testEndpointHasTheRightNumberOfImagesWithoutExpressions(testcase){
	var query = "select distinct ?image where {?image rdf:type flyted:Image. " +
			"OPTIONAL {?image flyted:expression ?expression }. FILTER ( !bound(?expression)) }";
	var failureMessage = "There should be 64 images.";
	
	var callback = {
			success: testSelectQueryExpectNumBindingsResponseSuccess(testcase, 64, failureMessage),
			failure: genericResponseFailure(testcase)
		};
		
	// define SPARQL query & URL
	query = sparqlns + query;
	var url = "flyted?output=json&query=" + escape(query);
	log("Unescaped query: "+query);
		
	log("Make the request to "+url);
	var request = YAHOO.util.Connect.asyncRequest("GET", url, callback, null);
		
	log("Suspend the test runner");
	testcase.wait();
}

function testAmbiguousT2BMappingsAreFixed (testCase) {
	log("Test \"==== testAmbiguousT2BMappingsAreFixed ====\" started.");
	
	var expectedUnambiguousT2BMappings = [
		["smooth", "http://openflydata.org/id/flybase/feature/FBgn0003435"],
		["B52", "http://openflydata.org/id/flybase/feature/FBgn0004587"],
		["fdl", "http://openflydata.org/id/flybase/feature/FBgn0045063"],
		["rbf", "http://openflydata.org/id/flybase/feature/FBgn0015799"],
		["bam", "http://openflydata.org/id/flybase/feature/FBgn0000158"],
		["l(1)G0255", "http://openflydata.org/id/flybase/feature/FBgn0028336"],
		["pip", "http://openflydata.org/id/flybase/feature/FBgn0003089"],
		["sip2", "http://openflydata.org/id/flybase/feature/FBgn0031878"],
		["Srp54", "http://openflydata.org/id/flybase/feature/FBgn0024285"],
		["And", "http://openflydata.org/id/flybase/feature/FBgn0011273"],
		["CG11765", "http://openflydata.org/id/flybase/feature/FBgn0033518"],
		["sdt", "http://openflydata.org/id/flybase/feature/FBgn0243505"],
		["l(2)02045", "http://openflydata.org/id/flybase/feature/FBgn0010504"],
		["Cam", "http://openflydata.org/id/flybase/feature/FBgn0000253"],
		["CG10022", "http://openflydata.org/id/flybase/feature/FBgn0051960"],
		["twe", "http://openflydata.org/id/flybase/feature/FBgn0002673"],
		["sd", "http://openflydata.org/id/flybase/feature/FBgn0003345"],
		["dsh", "http://openflydata.org/id/flybase/feature/FBgn0000499"],
		["swa", "http://openflydata.org/id/flybase/feature/FBgn0003655"],
		["spin", "http://openflydata.org/id/flybase/feature/FBgn0086676"],
		// "* mle -> FBal0012332 FBgn0002774","FBgn0002715","maleless", 
		// assume Helen's error, mle is FBgn0002774 (maleless)
		["mle", "http://openflydata.org/id/flybase/feature/FBgn0002774"],
		// "* mei-S332 -> FBal0012188 FBgn0002715  "
		// assume Helen's error, mei-S332 is FBgn0002715 (meiotic from via Salaria 332)
		["mei-S332", "http://openflydata.org/id/flybase/feature/FBgn0002715"],
		["acer", "http://openflydata.org/id/flybase/feature/FBgn0016122"],
		["TektinA", "http://openflydata.org/id/flybase/feature/FBgn0028902"],
		["mi-2", "http://openflydata.org/id/flybase/feature/FBgn0013591"],
		["Mst-35Ba", "http://openflydata.org/id/flybase/feature/FBgn0013300"],
		["Hex T2", "http://openflydata.org/id/flybase/feature/FBgn0042710"],
		["CG12819/sle", "http://openflydata.org/id/flybase/feature/FBgn0037810"],
		["scpr-b", "http://openflydata.org/id/flybase/feature/FBgn0037888"],
		["prx2540", "http://openflydata.org/id/flybase/feature/FBgn0033520"],
		["Acp63.F", "http://openflydata.org/id/flybase/feature/FBgn0015585"],
		// TODO Helen is unsure about this, needs to look at primer sequence
		// "est-2" 
		["nfx4", "http://openflydata.org/id/flybase/feature/FBgn0051501"],
		["CG10998/r-cup", "http://openflydata.org/id/flybase/feature/FBgn0031142"],
		["aurora b", "http://openflydata.org/id/flybase/feature/FBgn0024227"],
		["CG10723/Kua", "http://openflydata.org/id/flybase/feature/FBgn0032850"],
		["Mfn/Marf", "http://openflydata.org/id/flybase/feature/FBgn0029870"],
		["mst87f", "http://openflydata.org/id/flybase/feature/FBgn0002862"],
		["so-c", "http://openflydata.org/id/flybase/feature/FBgn0003460"],
		["so-n", "http://openflydata.org/id/flybase/feature/FBgn0003460"],
		["CG32394N", "http://openflydata.org/id/flybase/feature/FBgn0052394"],
		["mat1", "http://openflydata.org/id/flybase/feature/FBgn0024956"],
		["CG4700-sema-2a", "http://openflydata.org/id/flybase/feature/FBgn0011260"],
		["mst35ba", "http://openflydata.org/id/flybase/feature/FBgn0013300"],
		["CG31992-gw", "http://openflydata.org/id/flybase/feature/FBgn0051992"],
		["sapr", "http://openflydata.org/id/flybase/feature/FBgn0000416"],
		["rpn6", "http://openflydata.org/id/flybase/feature/FBgn0028689"],
		["CG7570/hale", "http://openflydata.org/id/flybase/feature/FBgn0036924"],
		["alh", "http://openflydata.org/id/flybase/feature/FBgn0037471"],
		["su(tpl)", "http://openflydata.org/id/flybase/feature/FBgn0014037"],
		["CG14016/tomb", "http://openflydata.org/id/flybase/feature/FBgn0031715"],
		["Pi3k59F", "http://openflydata.org/id/flybase/feature/FBgn0015277"],
		["Cct-2", "http://openflydata.org/id/flybase/feature/FBgn0035231"],
		["CG17736/schuy", "http://openflydata.org/id/flybase/feature/FBgn0036925"],
		["d-cup", "http://openflydata.org/id/flybase/feature/FBgn0038089"],
		// ["prosalpha1", "FBgn0026781 AND FBgn0050382"], // N.B. Helen says there is a gene duplication event, so genes are identical
        ["prosalpha1", "http://openflydata.org/id/flybase/feature/FBgn0026781"],
        ["prosalpha1", "http://openflydata.org/id/flybase/feature/FBgn0050382"],
		["Nrx4", "http://openflydata.org/id/flybase/feature/FBgn0013997"],
		["tfb1", "http://openflydata.org/id/flybase/feature/FBgn0033929"],
		["SlgA", "http://openflydata.org/id/flybase/feature/FBgn0003423"],
		["p-cup", "http://openflydata.org/id/flybase/feature/FBgn0030840"],
		["CR32886-Uhg1", "http://openflydata.org/id/flybase/feature/FBgn0045800"],
		["swapsi", "http://openflydata.org/id/flybase/feature/FBgn0016974"],
		["Rno", "http://openflydata.org/id/flybase/feature/FBgn0035106"],
		["CG10034/tj", "http://openflydata.org/id/flybase/feature/FBgn0000964"],
		["cirl", "http://openflydata.org/id/flybase/feature/FBgn0033313"],
		["des/ifc", "http://openflydata.org/id/flybase/feature/FBgn0001941"],
		["Pros28.1b", "http://openflydata.org/id/flybase/feature/FBgn0017556"] 
	];
	
	for (var i=0; i<expectedUnambiguousT2BMappings.length; i++) {
		
		var mapping = expectedUnambiguousT2BMappings[i];
		var t = mapping[0];
		var b = mapping[1];	 
		
//		var query = "select ?feature from <http://naxos.zoo/flyted-2008-12-02-5> where {<http://openflydata.org/id/flyted/probe/"+ t +"> flyted:hybridisesTranscriptOf ?feature.}";
        var query = "select ?feature where {<http://openflydata.org/id/flyted/probe/"+ t +"> flyted:hybridisesTranscriptOf ?feature.}";
		var failureMessage = "There should be no mappings.";
	
		var callback = {
			success: testRightSelectQueryResponseSuccess(testCase, b, failureMessage),
			failure: genericResponseFailure(testCase)
		};
		
		// define SPARQL query & URL
		query = sparqlns + query;
		var url = "flyted?output=json&query=" + escape(query);
		log("Unescaped query: "+query);
		
		log("Make the request to "+url);
		var request = YAHOO.util.Connect.asyncRequest("GET", url, callback, null);
		
		log("Suspend the test runner");
		testCase.wait();
	}
	
};

function testB2TMappings (testCase) {
	log("Test \"==== testB2TMappings ====\" started.");
	
	var expectedB2TMappings = [
		// test the effects of probe cv
        ["FBgn0042710", 1],        
        // added assumed typo variant CG10998
        ["FBgn0031142", 1],
        // added assumed typo variant hale
        ["FBgn0036924", 1],
        // added assumed typo variant schuy
        ["FBgn0036925", 1],
        // TODO check this one to many mapping is valid//d-cup
        ["FBgn0038089", 1],
        ["FBgn0032859", 1], // ArcP34
        ["FBgn0037462", 1], //sunz|CG15179
        ["FBgn0030840", 1],// p-cup
        ["FBgn0032439", 1], //ref2|CG17031)
        ["FBgn0002838", 1],//ms\\(3\\)K81|CG14251
		// added Prosalpha6 because assume same primer 
        ["FBgn0026781", 1],
        ["FBgn0050382", 1],  // TODO this fails, fixme
        ["FBgn0052548", 2],
        ["FBgn0010747", 1],
        ["FBgn0024285", 1],
        ["FBgn0042189", 2],
        ["FBgn0052392", 2],
        ["FBgn0004903", 1],
        ["FBgn0015799", 1],
        ["FBgn0016122", 1],
        ["FBgn0028902", 1],
        ["FBgn0013591", 1],
        ["FBgn0037810", 1],        
        ["FBgn0037888", 1],
        ["FBgn0033520", 1],
        ["FBgn0015585", 1],
	    ["FBgn0051501", 1],                
        ["FBgn0024227", 1],
        ["FBgn0032850", 1],
        ["FBgn0029870", 1],
        ["FBgn0002862", 1],
        ["FBgn0003460", 2],
        ["FBgn0052394", 1],
        ["FBgn0024956", 1],
        ["FBgn0011260", 1],
        ["FBgn0051992", 1],
        ["FBgn0000416", 1],
        ["FBgn0028689", 1],
        ["FBgn0037471", 1],
        ["FBgn0014037", 1],
        ["FBgn0031715", 1],
        ["FBgn0015277", 1],
        ["FBgn0035231", 1],
	    ["FBgn0013997", 1],
        ["FBgn0033929", 1],
        ["FBgn0003423", 1],
        ["FBgn0045800", 1],
        ["FBgn0016974", 1],
        ["FBgn0035106", 1],
        ["FBgn0000964", 1],
        ["FBgn0033313", 1],
        ["FBgn0001941", 1],
        ["FBgn0017556", 1] 
        ];   
        
    for (var i=0; i<expectedB2TMappings.length; i++) {
		var mapping = expectedB2TMappings[i];
		var b = mapping[0];
		var t = mapping[1];
		
//		var query = "select distinct ?probe from <http://naxos.zoo/flyted-2008-12-02-5> where {?probe flyted:hybridisesTranscriptOf <http://openflydata.org/id/flybase/feature/" + b + ">.}";
        var query = "select distinct ?probe where {?probe flyted:hybridisesTranscriptOf <http://openflydata.org/id/flybase/feature/" + b + ">.}";
		var failureMessage = "There should be no mappings.";
	
		var callback = {
			success: testSelectQueryExpectNumBindingsResponseSuccess (testCase, t, failureMessage),
			failure: genericResponseFailure(testCase)
		};
		
		// define SPARQL query & URL
		query = sparqlns + query;
		var url = "flyted?output=json&query=" + escape(query);
		log("Unescaped query: "+query);
		
		log("Make the request to "+url);
		var request = YAHOO.util.Connect.asyncRequest("GET", url, callback, null);
		
		log("Suspend the test runner");
		testCase.wait();		
	}
}


//function testEndpointHasTheRightNumberOfImages(testcase){
//	var query = "select ?image where {?image rdf:type flyted:Image}";
//	var failureMessage = "There should be 2596 images.";
//	
//	var callback = {
//			success: testSelectQueryExpectNumBindingsResponseSuccess(testcase, 2596, failureMessage),
//			failure: genericResponseFailure(testcase)
//		};
//		
//	// define SPARQL query & URL
//	query = sparqlns + query;
//	var url = "flyted?output=json&query=" + escape(query);
//	log("Unescaped query: "+query);
//		
//	log("Make the request to "+url);
//	var request = YAHOO.util.Connect.asyncRequest("GET", url, callback, null);
//		
//	log("Suspend the test runner");
//	testcase.wait();
//}

var pause = 500;

var flytedTestCase = new YAHOO.tool.TestCase({

	name: "FlyTED SPARQL Endpoint Test Case",
	
	testEndpointExists : function() {
		var tc = this;
        tc.wait(function() {testEndpointExists(tc);}, pause);
	},
	
	testEndpointHasData : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasData(tc);}, pause);
	},
	
	testEndpointHasImages : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasImages(tc);}, pause);
	},
	
	testEndpointImageURIsAreValid : function() {
        var tc = this;
		tc.wait(function() {testEndpointImageURIsAreValid(tc);}, pause);
	},
	
	testEndpointHasImagesWithProbes : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasImagesWithProbes(tc);}, pause);
	},
	
	testEndpointHasNoImagesWithoutProbes : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasNoImagesWithoutProbes(tc);}, pause);
	},
	
	testEndpointHasImagesWithSpecificProbe : function() {
        var tc = this;
        var testProbes = ['Adh', 'CG10151', 'so-c', 'so-n', 'Srp54k', 'Srp54', 'aurara b', 'lamina ancestor', 'Prosalpha6T', 'Prosalpha6']
        for (var probe in testProbes){
			tc.wait(function() {testEndpointHasImagesWithSpecificProbe(tc,testProbes[probe], true);}, pause);
        }
	},
	
	testEndpointNotHasSpecificProbes : function(){
		var tc = this;
		var probes = ["Hex-T2", "d-cup", "ArcP34", "CG15179", "p-cup", "CG17031", "CG10998/r-cup", "prosalpha1", "CG17736/schuy", "CG7570/hale", "ms(3)K81", "Mst-35Ba", "mst35ba"];
		for (var probe in probes){
			tc.wait(function() {testEndpointNotHasSpecificProbes(tc, probes[probe]);}, pause);
		}
	},
	
	testEndpointHasImageWithThumbnails : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasImageWithThumbnails(tc);}, pause);
	},
	
	testEndpointHasNoImagesWithoutThumbnails : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasNoImagesWithoutThumbnails(tc);}, pause);
	},

	testEndpointHasImageWithSeeAlso : function(){ 
        var tc = this;
		tc.wait(function() {testEndpointHasImageWithSeeAlso(tc)}, pause);
	},
	
	testEndpointHasNoImagesWithoutSeeAlso : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasNoImagesWithoutSeeAlso(tc)}, pause);
	},
	
	testEndpointHasImageWithGenotype : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasImageWithGenotype(tc);}, pause);
	},
	
	testEndpointHasNoImagesWithoutGenotype : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasNoImagesWithoutGenotype(tc);}, pause);
	},
	
	testEndpointHasImagesWithSpecificGenotypeWt : function(){
        var tc = this;
		tc.wait(function() {testEndpointHasImagesWithSpecificGenotype(tc, "wt");}, pause); 
	},
	
	testEndpointHasImagesWithSpecificGenotypeAly : function(){
        var tc = this;
		tc.wait(function() {testEndpointHasImagesWithSpecificGenotype(tc, "aly");}, pause);
	},
	
	testEndpointHasImagesWithSpecificGenotypeAccessoryGland : function(){
        var tc = this;
		tc.wait(function() {testEndpointHasImagesWithSpecificGenotype(tc, "accessory_gland");}, pause); 
	},
	
	testEndpointHasImageWithExpressions : function () {
        var tc = this;
		tc.wait(function() {testEndpointHasImageWithExpressions(tc);}, pause); 
	},
	
	testEndpointHasImagesWithSpecificExpressionWithNoStraining : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasImagesWithSpecificExpression(tc, "No_staining");}, pause); 
	},
	
	testEndpointHasImagesWithSpecificExpressionWithEarlyPrimarySpermatocytes : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasImagesWithSpecificExpression(tc, "Early_primary_spermatocyte");}, pause); 
	}, 
	
	testEndpointHasImagesWithSpecificExpressionLateCystCells : function() {
        var tc = this;
		tc.wait(function() {testEndpointHasImagesWithSpecificExpression(tc, "Cyst_cell_of_spermatid");}, pause); 
	}, 
	
	testEndpointHasNoImagesWithoutExpressions : function(){
        var tc = this;
		tc.wait(function() {testEndpointHasNoImagesWithoutExpressions(tc);}, pause);
	},
	
	testEndpointHasTheRightNumberOfImagesWithoutExpressions : function(){
        var tc = this;
		tc.wait(function() {testEndpointHasTheRightNumberOfImagesWithoutExpressions(tc);}, pause);
	},
	
	testEndpointHasFlyBaseGeneFeature : function(){
		var tc = this;
		tc.wait(function() {testEndpointHasFlyBaseGeneFeature(tc);}, pause);
	},
	
	testEndpointHasProbesWithGeneMappings : function(){
		var tc = this;
		tc.wait(function() {testEndpointHasProbesWithGeneMappings(tc);}, pause);
	},
		
	testEndpointHasGeneMappingForSpecificProbes : function(){
		var tc = this;
		var probes = ["Hex T2", "d-cup", "ArcP34", "CG15179", "p-cup", "CG17031", "CG10998/r-cup", "prosalpha1", "CG17736/schuy", "CG7570/hale", "ms\\(3\\)K81", "Mst-35Ba", "mst35ba"];
		for (var probe in probes){
			tc.wait(function() {testEndpointHasGeneMappingForSpecificProbes(tc, probes[probe]);}, pause);
		}
	},
	
	testAmbiguousT2BMappingsAreFixed : function(){
		var tc = this;
		tc.wait(function() {testAmbiguousT2BMappingsAreFixed(tc);}, pause);
	},
	
	testB2TMappings : function(){
		var tc = this;
		tc.wait(function() {testB2TMappings(tc);}, pause);
	}
	
})	

function setupLogger() {
    var loggerConfig = {
        thresholdMax : 100000,
        thresholdMin : 100000
    };
    var loggerContainer = document.getElementById("logger");
    var testLogger = new YAHOO.tool.TestLogger(loggerContainer, loggerConfig);
//	var logReader = new YAHOO.tool.TestLogger("logger");
	YAHOO.log("Logger setup done");	
}

function runTests() {
	YAHOO.log("Running tests");
	YAHOO.tool.TestRunner.add(flytedTestCase);
	YAHOO.tool.TestRunner.run();
}

YAHOO.util.Event.onDOMReady(setupLogger);
YAHOO.util.Event.onDOMReady(runTests);

